﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace FYPHP
{
    public partial class ViewStaffProfile : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["fyphp"].ConnectionString);


        protected void Page_Load(object sender, EventArgs e)
        {
            SqlCommand cmdUser;
            SqlDataReader dtrUser;
            conn.Open();

            cmdUser = new SqlCommand("Select * From Users where u_id = @Id", conn);
            cmdUser.Parameters.AddWithValue("@Id",Session["ID"].ToString());
            dtrUser = cmdUser.ExecuteReader();
            dtrUser.Read();

            String userName = dtrUser["username"].ToString();
            String gender = dtrUser["u_gender"].ToString();
            String age = dtrUser["u_age"].ToString();
            string addressBeforeSplit = dtrUser["u_address"].ToString();

            string[] lines = addressBeforeSplit.Split('|');

            string address = "";

            foreach (string line in lines)
            {
                address += " " + line;
            }
            String email = dtrUser["u_email"].ToString();
            String rewardpoint = dtrUser["u_points"].ToString();
            String UserStatus = dtrUser["u_status"].ToString();
            String PhoneNo = dtrUser["u_phone"].ToString();

            lblPID.Text = Session["ID"].ToString();
            lblName.Text = userName;
            lblGender.Text = gender;
            lblAge.Text = age;
            lblAddress.Text = address;
            lblEmail.Text = email;
            lblRewardPoints.Text = rewardpoint;
            lblPhoneNo.Text = PhoneNo;

            dtrUser.Close();
            conn.Close();

       
        }

        public String return_userpicture()
        {
            SqlCommand cmdUser;
            SqlDataReader dtrUser;
            conn.Open();

            cmdUser = new SqlCommand("Select * From Users", conn);
            dtrUser = cmdUser.ExecuteReader();
            dtrUser.Read();
            String userPicture = dtrUser["u_picture"].ToString();

            conn.Close();

            return userPicture;

        }

        protected void EditProfile_Click(object sender, EventArgs e)
        {
            Response.Redirect("EditProfile.aspx");



        }

        protected void EditProfile_Click1(object sender, EventArgs e)
        {
            Response.Redirect("EditStaffProfile.aspx");
        }

   

  
    }
}